package cn.wolfcode.web.controller;

import cn.wolfcode.common.web.Result;
import cn.wolfcode.domain.OperateIntergralVo;
import cn.wolfcode.domain.UsableIntegral;
import cn.wolfcode.service.IUsableIntegralService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/intergral")
public class IntegralController {
    @Autowired
    private IUsableIntegralService usableIntegralService;

    @GetMapping("/getByUserId")
    public Result<UsableIntegral> getByUserId(Long userId) {
        return Result.success(usableIntegralService.getByUserId(userId));
    }

    @PostMapping("/pay")
    public Result<String> pay(Long userId, Long amount) {
        usableIntegralService.decrment(userId, amount);
        return Result.success("");
    }
}
